package mamma.action;

import java.util.List;
import java.util.Map;

import mamma.dao.CalendarDao;
import mamma.vo.CalendarVo;
import mamma.vo.InformationVo;
import mamma.vo.MemberVo;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class CalendarAction extends ActionSupport {

	private int id;
	private int importance;

	private String infoName;
	private String infoContent;
	private String startDate;
	private String endDate;
	private String loginId;
	private String email;


	private CalendarVo vo;
	private InformationVo info;
	private MemberVo memberVo;

	private List<InformationVo> infoList=null,infoList2=null;
	
	public String check(){
		ActionContext context = ActionContext.getContext();
		Map<String, Object> session = context.getSession();
		memberVo = (MemberVo)session.get("login");
		loginId = memberVo.getEmail();
		
		return SUCCESS;
	}

	public String clist() throws Exception{
		infoList=new CalendarDao().clist();
		infoList2=new CalendarDao().clist2();
		System.out.println("다녀감");
		return SUCCESS;
	}

	public String insertSchedule() throws Exception{
		System.out.println("입력ㄱㄱ");
		
		ActionContext context = ActionContext.getContext();
		Map<String, Object> session = context.getSession();
		memberVo = (MemberVo)session.get("login");
		loginId = memberVo.getEmail();
		
		vo=new CalendarVo();
		vo.setInfoName(infoName);
		vo.setInfoContent(infoContent);
		vo.setStartDate(startDate);
		vo.setEndDate(endDate);
		vo.setEmail(loginId);
		System.out.println(vo.toString());
		new CalendarDao().scheduleIns(vo);

		return SUCCESS;
	}

	public String scheduleDel() throws Exception{
		new CalendarDao().scheduleDelC(id);
		return SUCCESS;
	}

	public String scheduleShiftC() throws Exception{
		
		ActionContext context = ActionContext.getContext();
		Map<String, Object> session = context.getSession();
		memberVo = (MemberVo)session.get("login");
		loginId = memberVo.getEmail();
		
		vo=new CalendarVo();
		vo.setId(id);
		vo.setStartDate(startDate);
		vo.setEndDate(endDate);
		vo.setEmail(loginId);
		System.out.println(vo.toString());
		new CalendarDao().scheduleShiftC(vo);
		System.out.println("되나요?");

		return SUCCESS;
	}

	public String scheduleUpd() throws Exception{
		ActionContext context = ActionContext.getContext();
		Map<String, Object> session = context.getSession();
		memberVo = (MemberVo)session.get("login");
		loginId = memberVo.getEmail();
		
		vo=new CalendarVo();
		vo.setId(id);
		vo.setInfoName(infoName);
		vo.setInfoContent(infoContent);
		vo.setEmail(loginId);
		new CalendarDao().scheduleUpd(vo);
		System.out.println("수정요?");
		System.out.println(vo.toString());
		return SUCCESS;
	}
	public String scheduleScr() throws Exception{
		ActionContext context = ActionContext.getContext();
		Map<String, Object> session = context.getSession();
		memberVo = (MemberVo)session.get("login");
		loginId = memberVo.getEmail();
		
		vo=new CalendarVo();
		vo.setId(id);
		vo.setEndDate(endDate);
		vo.setEmail(loginId);
		new CalendarDao().scheduleScr(vo);
		System.out.println("수정요?");
		System.out.println(vo.toString());
		return SUCCESS;
	}
	
	public String selectNews(){
		CalendarDao dao = new CalendarDao();
		infoList =  dao.selectNews();
		
		return SUCCESS;
	}
	 

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getInfoName() {
		return infoName;
	}

	public void setInfoName(String infoName) {
		this.infoName = infoName;
	}

	public String getInfoContent() {
		return infoContent;
	}

	public void setInfoContent(String infoContent) {
		this.infoContent = infoContent;
	}

	public String getStartDate() {
		return startDate;
	}

	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}

	public String getEndDate() {
		return endDate;
	}

	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}

	public int getImportance() {
		return importance;
	}

	public void setImportance(int importance) {
		this.importance = importance;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public CalendarVo getVo() {
		return vo;
	}

	public void setVo(CalendarVo vo) {
		this.vo = vo;
	}

	public List<InformationVo> getInfoList() {
		return infoList;
	}

	public void setInfoList(List<InformationVo> infoList) {
		this.infoList = infoList;
	}

	public List<InformationVo> getInfoList2() {
		return infoList2;
	}

	public void setInfoList2(List<InformationVo> infoList2) {
		this.infoList2 = infoList2;
	}

	public InformationVo getInfo() {
		return info;
	}

	public void setInfo(InformationVo info) {
		this.info = info;
	}

	public String getLoginId() {
		return loginId;
	}

	public void setLoginId(String loginId) {
		this.loginId = loginId;
	}

	public MemberVo getMemberVo() {
		return memberVo;
	}

	public void setMemberVo(MemberVo memberVo) {
		this.memberVo = memberVo;
	}
	
}
